<template>
	<view class="container">
		<Header>委员风采</Header>
		<scroll-view class="content">
			<view class="title">
				{{data.title}}
			</view>
			<view class="date">
				<span>{{data.createtime}}</span>
			</view>
			<view v-html="data.content"></view>
			
			<view class="bottom">
				<view class="item" :class="{active: data.like==1}" @click="dlikecCollect(1)">
					<uni-icons type="hand-up-filled" size="30"></uni-icons>
				</view>
				<view class="item" :class="{active: data.collect==1}" @click="dlikecCollect(2)">
					<uni-icons type="star-filled" size="30"></uni-icons>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import Header from '../../components/header.vue'
	import request from '../../common/request.js'
	export default {
		components: {
			Header
		},
		data() {
			return {
				id: '',
				data:{}
			}
		},
		onLoad(option) {
			this.id  = option.id
		},
		mounted(){
			this.getDetailData()
		},
		methods: {
			dlikecCollect(type) {
				request({
					url: '/member/dlikecCollect',
					data: {
						fcstudy_id: this.id,
						type: type
					},
					method: 'POST'
				}).then(res => {
					if (res.code == 1) {
						let msg = ''
						if (type == 1) {
							if (this.data.like == 1) {
								this.data.like = 0
								msg = '取消点赞'
							} else {
								this.data.like = 1
								msg = '点赞成功'
							}
						} else {
							if (this.data.collect == 1) {
								this.data.collect = 0
								msg = '取消收藏'
							} else {
								this.data.collect = 1
								msg = '收藏成功'
							}
						}
						uni.showToast({
							title: msg,
							icon: 'none',
							duration: 2000
						});
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
			getDetailData(){
				request({
					url:'/member/detail',
					data:{
						fcstudy_id: this.id
					},
					method: 'POST'
				}).then(res => {
					if(res.code == 1){
						this.data = res.data
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		background-color: #f2f2f2;
		min-height: calc(100vh - 10px);
		padding-bottom: 5px;
	}
	.content{
		min-height: calc(100vh - 70px);
		width: calc(100% - 16px);
		background-color: #fff;
		margin: 10px 8px;
		border-radius: 15px;
		overflow: hidden;
		padding: 15px;
		box-sizing: border-box;
		line-height: 30px;
	}
	.title{
		font-size: 16px;
		font-weight: bold;
		text-align: center;
		line-height: 26px;
	}
	.date{
		font-size: 14px;
		text-align: center;
		margin: 15px 0px;
	}
	.date span{
		margin: 0px 10px;
	}
	.bottom {
		/* position: sticky;
		bottom: 10px; */
		margin: 10px 0px;
		display: flex;
		align-items: center;
		justify-content: center;
	
		.item {
			border: 1px solid #e2e2e2;
			display: inline-block;
			width: 50px;
			height: 50px;
			border-radius: 50%;
			display: flex;
			align-items: center;
			justify-content: center;
			margin: 0px 15px;
	
			&.active {
				::v-deep .uni-icons {
					color: #ea5b6a !important;
				}
			}
		}
	}
</style>